package home;

import java.util.List;

import operations.HibernateManager;

import org.hibernate.Criteria;
import org.hibernate.classic.Session;
import org.hibernate.criterion.Expression;

import teams.Team;

public class TeamHome {

    public List<Team> getAllTeams() {
        Session session = HibernateManager.instance().getSession();
        Criteria criteria = session.createCriteria(Team.class);
        return criteria.list();

    }

    public Team getByName(final String nombre) {
        Session session = HibernateManager.instance().getSession();
        Criteria criteria = session.createCriteria(Team.class).add(Expression.eq("name", nombre));
        return (Team) criteria.uniqueResult();
    }

}
